<template>
	<view class="headerall">
		<carHeader :title="'我的订单'"></carHeader>
		<!-- 维修方式下拉框 和预约日期 -->
		<view class="chouse">
			<text class="t1">维修方式：</text>
			<view class="xiala">
				<uni-data-select style="border: 0rpx;" placeholder="全部" v-model="value" :localdata="range"
					@change="change"></uni-data-select>
			</view>
			<view class="tanchu" @click="showPopup">
				<image src="../../static/车联网服务-08我的-03我的维修_slices/日期.png" mode=""></image>
				<text>预约日期</text>
			</view>

			<!-- Popup内容 -->
			<view v-if="popupVisible" class="popup" :style="popupStyle">
				<text class="t1">开始时间:</text>
				<view class="timestart">
					<uni-datetime-picker type="datetime" v-model="datetimesingle1" @change="changeLog1" />
				</view>

				<text class="t2">结束时间:</text>
				<view class="timeend">
					<uni-datetime-picker type="datetime" v-model="datetimesingle2" @change="changeLog2" />
				</view>
				<u-button class="btn1" type="primary" size="small" text="确定" @click="hidePopup"></u-button>
			</view>

			<view @click="goToDetail" class="dataall" v-for="(item, index) in maintenanceList" :key="index">
				<view class="v1">维修单号：<text>{{ item.orderId }}</text></view>
				<view class="v2">维修方式：<text>{{ item.serviceType }}</text></view>
				<view class="v3">预约日期：<text>{{ item.appointmentDate }}</text></view>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				range: [{
						value: 0,
						text: "到店维修"
					},
					{
						value: 1,
						text: "上门取车"
					}
				],
				popupVisible: false,
				datetimesingle1: '',
				datetimesingle2: '',
				// 假设这是你的维修单数据列表  
				maintenanceList: [{
						orderId: '3535252',
						serviceType: '上门取车',
						appointmentDate: '2024/08/12 17:11'
					},
					{
						orderId: '3535253',
						serviceType: '到店维修',
						appointmentDate: '2024/08/13 10:00'
					},
					{
						orderId: '3535254',
						serviceType: '远程指导',
						appointmentDate: '2024/08/14 15:30'
					}
				]
			};
		},
		mounted() {
			setTimeout(() => {
					this.datetimesingle1 = Date.now() - 2 * 24 * 3600 * 1000
				}, 3000),
				setTimeout(() => {
					this.datetimesingle2 = Date.now() - 2 * 24 * 3600 * 1000
				}, 3000)
		},
		methods: {
			change(e) {
				console.log("e:", e);
			},
			toggle(type) {
				this.type = type
				// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
				this.$refs.popup.open(type)
			},
			showPopup() {
				this.popupVisible = true;
				// 这里可以添加逻辑来动态调整popupStyle（如果需要的话）  
			},
			hidePopup() {
				this.popupVisible = false;
			},
			changeLog1(e) {
				console.log('change事件:', e);
			},
			changeLog2(e) {
				console.log('change事件:', e);
			},
			goToDetail() {
				// 使用uni.navigateTo跳转到详情页面  
				uni.navigateTo({
					url: '/pages/wodeweixiu03/wodeweixiu03' // 假设详情页面的路径是/pages/detail/detail  
				});
			}
		}
	}
</script>

<style lang="scss">
	.headerall {
		.chouse {
			width: 95%;
			height: 130rpx;
			background-color: white;
			margin: 0 auto;
			position: relative;
			top: -200rpx;
			border-radius: 30rpx;

			.t1 {
				position: absolute;
				top: 40rpx;
				left: 20rpx;
				font-size: 30rpx;
			}

			.xiala {
				position: absolute;
				background-color: #55aaff;
				width: 160rpx;
				height: 70rpx;
				left: 180rpx;
				top: 25rpx;
				border-radius: 20rpx;
				color: black;
			}

			.tanchu {
				position: absolute;
				top: 35rpx;
				right: 40rpx;
				width: 170rpx;
				height: 50rpx;
				background-color: white;

				image {
					margin-top: 15rpx;
					width: 30rpx;
					height: 30rpx;
					margin-right: 15rpx;
				}

				text {
					position: relative;
					top: -5rpx;
					font-size: 30rpx;
				}
			}

			.popup {
				width: 95%;
				height: 300rpx;
				position: absolute;
				top: 90rpx;
				background-color: white;
				z-index: 2;

				.t1 {
					position: relative;
					top: 30rpx;
					left: 40rpx;
				}

				.t2 {
					position: relative;
					top: 10rpx;
					left: 40rpx;
				}

				.timestart {
					width: 60%;
					position: relative;
					top: -25rpx;
					left: 220rpx;
				}

				.timeend {
					width: 60%;
					position: relative;
					top: -40rpx;
					left: 220rpx;
				}
			}
		}

		.dataall {
			width: 95%;
			margin: 20rpx auto;
			height: 200rpx;
			padding-top: 20rpx;
			padding-left: 30rpx;
			background-color: white;
			border-radius: 30rpx;
			position: relative;
			top: 145rpx;
			z-index: 1;

			.v1 {
				margin-bottom: 30rpx;
				font-size: 30rpx;
			}

			.v2 {
				margin-bottom: 30rpx;
				font-size: 30rpx;
			}

			.v3 {
				font-size: 30rpx;
			}

			text {
				color: gray;
				font-size: 25rpx;
			}
		}
	}
</style>